<?php
// +--------------------------------------------------
// | Name: 星空框架  登录管理
// +--------------------------------------------------
// | Version: V5.0
// +--------------------------------------------------
// | Author: xkyinzhe <zhonghuaxinxing@sina.cn>
// +--------------------------------------------------
// | Time: 2021-05-19 09:26
// +--------------------------------------------------
declare(strict_types=1);

namespace app\xingkong\controller\v1;

use app\common\common\BackendController;
use app\common\model\Admin as AdminModel;
use think\facade\Session;
use think\facade\Db;
use think\facade\View;

/**
 * @xk 登录管理
 */
class Login extends BackendController
{
  /**
   * @xk 登录页面
   *
   * @method index
   * @return [type]                  [description]
   * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
   * @Time   2021-05-19T10:18:33+080
   */
  public function index(){
    return View::fetch();
  }
  /**
   * @xk 登录检测
   *
   * @method checkLogin
   * @param  AdminModel              $adminModel               [description]
   * @return [type]                                            [description]
   * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
   * @Time   2021-05-19T10:19:06+080
   */
  public function checkLogin(AdminModel $adminModel){
    $param = request()->param();
    $code = 200;
    $msg = '请求成功';
    $resultData = [];
    if($param){
      $result = $adminModel->checkLogin($param);
      $result_code = $result['result_code'];
      $result_msg = $result['result_msg'];
      $resultData['backUrl'] = $result['backUrl'];
    }
    $this->result($code,$msg,$result_code,$result_msg,$resultData);
  }
  /**
   * @xk 推出登录
   *
   * @method loginOut
   * @return [type]                  [description]
   * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
   * @Time   2021-05-19T11:00:29+080
   */
  public function loginOut(){
    Session::clear();
    $_loginUri = '/'.config('manage.manage_name').'/'.config('manage.version').'/Login';
    $this->success("退出登录成功",$_loginUri);
  }

}
